@extends('wechat.member-layout')

@section('content')
    <div class="container" id="container">
        <div class="weui_tab">
            <div class="weui_tab_bd">
                <div class="hd">
                    <h1 class="page_title">支付中...</h1>
                </div>
            </div>
        </div>
    </div>
@endsection
@section('js')
    <script src="http://{{ env('QINIU_DOMAIN') }}/js/zepto.min.js"></script>
    <script>
        function onBridgeReady(){
            WeixinJSBridge.invoke(
                'getBrandWCPayRequest', <?= $json ?>,
                function(res){
                    if(res.err_msg == "get_brand_wcpay_request:ok" ) {
                        setTimeout("window.location = 'http://{!! $domain !!}/wechat/view?id={{ $order->wechat_upload_id }}&_=' + new Date().getTime();", 500);
                    } else {
                        alert('没有成功支付，请重试');
                    }
                }
            );
        }
        if (typeof WeixinJSBridge == "undefined"){
            if( document.addEventListener ){
                document.addEventListener('WeixinJSBridgeReady', onBridgeReady, false);
            } else if (document.attachEvent){
                document.attachEvent('WeixinJSBridgeReady', onBridgeReady);
                document.attachEvent('onWeixinJSBridgeReady', onBridgeReady);
            }
        }else{
            onBridgeReady();
        }
    </script>
@endsection